import { onMounted, onUnmounted } from "vue";
import { wsStore } from "../store/websocketStore";
import { WsMsgType } from "../model";

export type WsMsgCb = (data: any) => void;
export const useWs = (ev: WsMsgType, cb: WsMsgCb) => {
  const clear = wsStore.on(ev, cb);

  onUnmounted(() => {
    clear();
  });
};
